package com.chaosj.skill.grpc

import io.grpc.ManagedChannel
import io.grpc.ManagedChannelBuilder
import static com.chaosj.skill.grpc.GreeterGrpc.*

/**
 * @Description:
 * @author: caoyangjie
 * @date: 2019年12月2019/12/6日 15:28
 * @Copyright: © 赢时胜
 */
class ClientCallGrpcService {
    static void main(args){
        ManagedChannelBuilder channelBuilder = ManagedChannelBuilder.forAddress("192.168.3.78",9999).usePlaintext()
        ManagedChannel channel = channelBuilder.build()

        GreeterBlockingStub stub = GreeterGrpc.newBlockingStub(channel)
        HelloWorldProtos.HelloReply reply = stub.sayHello(HelloWorldProtos.HelloRequest.newBuilder().setMessage("hello!this is client!").build())
        println(reply.getMessage())
        reply = stub.sayHello(HelloWorldProtos.HelloRequest.newBuilder().setMessage("hello world!").build())
        println(reply.getMessage())
    }
}
